#!/usr/bin/env python3
"""
快速测试10秒合约
"""

import asyncio
import json
import websockets

async def quick_test():
    """快速测试"""
    try:
        async with websockets.connect("ws://localhost:8768") as websocket:
            print("✅ 连接成功!")
            
            # 创建用户
            await websocket.send(json.dumps({
                "action": "create_user",
                "username": "快速测试"
            }))
            user_response = await websocket.recv()
            user_data = json.loads(user_response)
            print(f"用户: {user_data}")
            
            if user_data.get("success"):
                user_id = user_data["user"]["id"]
                
                # 创建10秒合约
                await websocket.send(json.dumps({
                    "action": "create_contract",
                    "user_id": user_id,
                    "symbol": "ETHUSDT",
                    "period": "10s",
                    "direction": "up",
                    "bet_amount": 100
                }))
                
                contract_response = await websocket.recv()
                contract_data = json.loads(contract_response)
                print(f"合约: {contract_data}")
                
    except Exception as e:
        print(f"错误: {e}")

if __name__ == "__main__":
    asyncio.run(quick_test())
